package com.auction.controller;

import com.auction.common.core.controller.MyBaseController;
import com.auction.common.dao.bean.PageResult;
import com.auction.common.utils.ReturnResult;
import com.auction.entity.Shop;
import com.auction.service.ShopService;
import com.auction.util.ShopQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "店铺")
@RequestMapping("/api/shop")
public class ShopController extends MyBaseController {

    @Autowired
    ShopService shopService;


    @PostMapping("/add")
    @ApiOperation("店铺添加")
    public ReturnResult addShop(@RequestBody Shop shop) {
        int r = shopService.shopAdd(shop);
        return saveResult(r);
    }
    @PostMapping("/query")
    @ApiOperation("查询店铺")
    public ReturnResult queryShop(@RequestBody ShopQuery shopQuery) {
        PageResult<Shop> shopPageResult = shopService.queryByPage(shopQuery);
        return success("店铺列表",shopPageResult);
    }
    //改变商品状态
    @PutMapping("/update/status")
    @ApiOperation("商品状态修改")
    public ReturnResult updateShopStatus(@RequestBody Shop shop) {
            int res =shopService.updateStatus(shop.getId(),shop.getStatus());
            return updateResult(res);
    }
}
